<?php

/**
 * @author honestphan
 * @copyright 2012
 */
//G?i t?p tin giao di?n trong thu m?c view/theme/template tuong ?ng

defined('DSVH') or die('Restricted access');
include('model/m_home.php');
//include('model/m_tinhoatdong.php');
include('language/lang_tinhoatdong.php');
include('controller/c_thongke.php');
include('controller/c_block.php');
$page = $_GET['act'];
   switch($page){
        case 'view':
        
        $catid = $_REQUEST['cm'];
        $catdetail = getcattin($catid);
        
        $ref="http://".eregi_replace("/$","",(getenv(HTTP_HOST)?getenv(HTTP_HOST):$_SERVER['HTTP_HOST']).(getenv(REQUEST_URI)?getenv(REQUEST_URI):$_SERVER['REQUEST_URI']));
         
    	//lấy danh sach bang tin
    	$list_bangtin = getListbangtin(0,5);
    	$list_lkw = getListlienketweb(0,10);
        if($_REQUEST['page']==""){
        $page = 1;
        $start =1;
        }
        else{
                
        $page = $_REQUEST['page'];
             
        }
       //get input for class page
        $limit = 10;
        $start = ($page - 1) * $limit;
    	$list_tinhoatdong = getListtinhoatdong($start,$limit);
    	//$list_toptinhoatdong = getListtinhoatdong(0,1);
    
        $total = totaltinhoatdong();
        // paging
        $paging = new Pagination();
        $paging->total = $total;
        $paging->limit = $limit;
        $paging->url = "index.php?module=tinhoatdong&act=list&page={page}";
        $paging->page = $page;
        $pagination = $paging->render();
        
        $id = $_REQUEST['id'];
        $tinhoatdong = gettinhoatdong($id);
        if(!$tinhoatdong){
           header('LOCATION: index.php?module=home');  
           exit(); 
        }
        
       	$list_tinlienquan = getListtinhoatdonglienquan(0,5, substr($tinhoatdong['ten_tin_hoat_dong'],0,8));
        
        $title = $tinhoatdong['ten_tin_hoat_dong'];
    	$heading_title= home." - ".$catdetail['ten_cat_tin'];
        $keyword = $tinhoatdong['keyword'];
        $description = $tinhoatdong['general'];
    	require('view/theme/default/template/home/header.tpl'); 
    	require('view/theme/default/template/home/left.tpl'); 
    	require('view/theme/default/template/tinhoatdong/tinhoatdong_detail.tpl');
    	require('view/theme/default/template/home/footer.tpl');    
        break;
        
        case 'list':
        //lấy danh sach bang tin
    	//$list_bangtin = getListbangtin(0,5);
    	//$list_lkw = getListlienketweb(0,10);
    	
        $catid = $_REQUEST['cm'];
        $catdetail = getcattin($catid);
        
        
        if($_REQUEST['page']==""){
        $page = 1;
        $start =1;
        }
        else{
                
        $page = $_REQUEST['page'];
             
        }
       //get input for class page
        $limit = 10;
        $start = ($page - 1) * $limit;
        
        //$list_tinhoatdongtop = getlisttinhoatdongtop(0,1);
       	//$list_topmevabe = getListmevabe(0,1);
       	$list_tinhoatdong = getListtinhoatdongbycat($catid, $start, $limit);
        $total = totaltinhoatdongbycat($catid);
        
        // paging
        $paging = new Pagination();
        $paging->total = $total;
        $paging->limit = $limit;
        $paging->url = "index.php?module=tinhoatdong&act=list&cm=".$catid."&page={page}";
        $paging->page = $page;
        $pagination = $paging->render();
        
    	//$list_tinlienquan = getListtinhoatdonglienquan(0,5, substr($tinhoatdong['ten_tin_hoat_dong'],0,8));
        
            
        $title =home ."".$tinhoatdong['ten_tin_hoat_dong'];
    	$heading_title=home;
        
    	require('view/theme/default/template/home/header.tpl'); 
    	require('view/theme/default/template/home/left.tpl'); 
    	require('view/theme/default/template/tinhoatdong/tinhoatdong_list.tpl');
    	require('view/theme/default/template/home/footer.tpl');    
        
        break;
        
        
}
?>